package com.baibei.ebec.user.mine;

import android.os.Bundle;
import android.widget.TextView;

import com.baibei.ebec.user.R;
import com.baibei.ebec.user.R2;
import com.baibei.model.UserInfo;
import com.baibei.module.AppRouter;
import com.baibei.module.BasicActivity;
import com.baibei.ui.AppUI;
import com.rae.swift.Rx;
import com.rae.widget.dialog.DialogBuilder;
import com.rae.widget.dialog.IAppDialog;
import com.rae.widget.dialog.IAppDialogClickListener;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 企业用户
 * Created by ChenRui on 2017/8/10 0010 14:12.
 */
public class MineEnterpriseFragment extends MineFragment {

    public static MineEnterpriseFragment newInstance() {
        return new MineEnterpriseFragment();
    }

    @BindView(R2.id.tv_mobile)
    TextView mMobileView;

    @Override
    public int getLayoutId(Bundle bundle) {
        return R.layout.fm_mine_enterprise;
    }

    @Override
    public void onLoginClick() {
        // 个人信息
    }

    @Override
    protected void onLoadUserInfo(UserInfo userInfo) {
        super.onLoadUserInfo(userInfo);
        mMobileView.setText(Rx.blockingPhone(userInfo.getMobile()));
    }

    /**
     * 拼单吧
     */
    @Override
    public void onBillClick() {
        AppRouter.routeToMergeOrders(getContext());
    }

    /**
     * 帮助中心
     */
    @OnClick(R2.id.btn_help_center)
    public void onHelpCenterClick() {
        AppUI.toastInCenter(getContext(), "帮助中心");

    }

    /**
     * 退出登录
     */
    @OnClick(R2.id.btn_logout)
    public void onLogoutClick() {
        new DialogBuilder(getContext())
                .setMessage("是否退出登录？")
                .positiveButtonText("退出")
                .positiveButtonClickListener(new IAppDialogClickListener() {
                    @Override
                    public void onClick(IAppDialog dialog, int i) {
                        dialog.dismiss();
                        ((BasicActivity) getActivity()).logout();
                    }
                })
                .show();
    }

    /**
     * 关于我们
     */
    @OnClick(R2.id.btn_about_me)
    public void onAboutMeClick() {
        AppUI.toastInCenter(getContext(), "关于我们");
    }
}
